package com.sprboot.demo.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sprboot.demo.domain.vo.first.User;
import com.sprboot.demo.domain.vo.second.Customer;
import com.sprboot.demo.service.local.CustomerService;
import com.sprboot.demo.service.local.UserService;

@RestController
@RefreshScope // 用于客户端接受服务端的更新消息
public class HelloWordController {
	//@Value("${book.name}")
	private String bookName;
	//@Value("${user.name}")
	private String userName;
	
	@Autowired
	private CustomerService customerService;
	@Autowired
	private UserService userService;

	@RequestMapping("/demo/test")
	public String test() {
		return userName + ">>>" + bookName;
	}

	@RequestMapping("/book/name")
	public String getBookName() {
		return bookName;
	}

	@GetMapping("/user/{id}")
	public User getUserById(@PathVariable("id") Long id) {
		return userService.getUserById(id);
	}

	@GetMapping("/customer/{id}")
	public Customer getCusById(@PathVariable("id") Long id) {
		return customerService.getById(id);
	}

}
